package 异常.day1.demo6;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        String pass= null;
        try {
            pass = getPassword();
            try {
                int a=1/0;
            } catch (Exception e) {
                e.printStackTrace();
            }

        } catch (NullPointerException myExc) {
            System.out.println(myExc.getMessage());
        }catch (PasswordExec myExc) {
            System.out.println(myExc.getMessage());
        }catch (OrderExe myExc) {
            System.out.println(myExc.getMessage());
        }
        System.out.println(pass);


    }

    static String getPassword()throws PasswordExec,OrderExe {
        Scanner in=new Scanner(System.in);
        System.out.println("请输入密码：");
        String pass=in.next();

        if(pass.length()<6){
            throw new PasswordExec("你的密码太短了，至少6位！");
        }
        return pass;
    }
}
